Package excel.formatting

Source Code of excel.formatting.AsposeWorkingWithFonts

package excel.formatting;

import com.aspose.cells.Cell;
import com.aspose.cells.Cells;
import com.aspose.cells.Color;
import com.aspose.cells.Font;
import com.aspose.cells.FontUnderlineType;
import com.aspose.cells.Style;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;

public class AsposeWorkingWithFonts
{
  public static void main(String[] args) throws Exception
  {
    //Instantiating a Workbook object
    Workbook workbook = new Workbook();

    //Accessing the worksheet in the Excel file
    Worksheet worksheet = workbook.getWorksheets().get(0);
    Cells cells = worksheet.getCells();

    //Adding some value to cell
    Cell cell = cells.get("A1");
    cell.setValue("This is Aspose test of fonts!");

    //Setting the font name to "Times New Roman"
    Style style = cell.getStyle();
    Font font = style.getFont();
    font.setName("Courier New");
    font.setSize(24);
    font.setBold(true);
    font.setUnderline(FontUnderlineType.SINGLE);
    font.setColor(Color.getBlue());
    font.setStrikeout(true);
    //font.setSubscript(true);

    cell.setStyle(style);

    //Saving the modified Excel file in default format
    workbook.save("data/AsposeFonts.xls");
   
    System.out.println("Aspose Fonts Created.");
  }
}
TOP

Related Classes of excel.formatting.AsposeWorkingWithFonts

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.